<?php
include_once("../DAO/answerDAO.php");
include_once("Answer.php");

class QuestionResult
{
	public $QuestionId;
	public $QuestionIndex;
	public $AnswersList;
	
	public function CheckCorrect()
	{
		$answerDAO = new AnswerDAO();
		$answerList = $answerDAO->GetAnswersByQuestionId($this->QuestionId);
		$answerIds = split("_", $this->AnswersList);
		for($i = 0; $i < count($answerIds); $i++)
		{
			for($j = 0; $j < count($answerList); $j++)
			{
				if($answerIds[$i] == $answerList[$j]-> Id)
				{
					if($answerList[$j]->IsCorrect == 0)
						return false;
					else
						break;
				}
			}
		}
		$countCorrect = 0;
		for($j = 0; $j < count($answerList); $j++)
		{
			if($answerList[$j]->IsCorrect == 1)
			{
				$countCorrect++;
			}
		}
		if($countCorrect == count($answerIds))
			return true;
		else
			return false;
	}
}

?>